#include "../apue.h"

unsigned int sleep2(unsigned);
static void sig_int(int);

int main(void)
{
    unsigned unslept;
    if (signal(SIGINT, sig_int) == SIG_ERR)
        err_sys("signal(SIGINT) error");

    //kill(getpid(), SIGINT);

    unslept = sleep2(6);
    printf("sleep2 return: %u\n", unslept);
}

static void sig_int(int signo)
{
    int i,j;
    int k;

    printf("\nsig_int starting\n");
    for (i=0; i<300000; ++i)
        for (j=0; j<4000; ++j)
            k+= i*j;
    printf("\nsig_int finished\n");
}
